/*
 * Subject.java
 *
 * Created on 31 de Julho de 2007, 22:57
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package padroes;

import InterfacePersistencia.conexao.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Mateus
 */
public class NewMessageObservable {
    
    List<NewMessageObserver> observers = new ArrayList<NewMessageObserver>();
    /** Creates a new instance of Subject */
    public NewMessageObservable() {
    }
    
    public void addObservers(NewMessageObserver o){
        observers.add(o);
    }
    
    public void removeObservers(NewMessageObserver o){
        observers.remove(o);
    }
    
    public void notifyObservers(Messages message){
       Iterator it = observers.iterator();
       
    
       while(it.hasNext()){
           NewMessageObserver o = (NewMessageObserver) it.next();
           o.update(message, this);
       }
    }
    
}
